home *** CD-ROM | disk | FTP | other *** search
- /*
- * $
- * $ FILE : main.c
- * $ VERSION : 1
- * $ REVISION : 12
- * $ DATE : 08-Dec-93 19:34
- * $
- * $ Author : mvk
- * $
- *
- ** This demo shows you the possibility to make Gadgets
- ** with the EGS STACK-LANGUAGE. But remmber the egsgadbox.lib
- ** normaly you didn't need the STACK-LANGUAGE, because you can
- ** do the same stuff much easier with the egsgadbox.library
- ** (refer demo gadget).
- **
- **
- ** In this Files you will find some usefull routines
- ** for Open / Close Libraries and ErrorHandling
- **
- ** (c) by VIONA-Development
- **
- */
-
- #include "includes.c"
- #include "Global.h"
- #include "stack-language.c"
- #include "Eventloop.c"
- #include "InitMenu.c"
-
- BOOL InitLibraries(struct OpenStructTyp *);
- void CloseLibraries(struct OpenStructTyp *);
-
-
- /*
- ** Opens the libs form the OpenStructTyp
- ** (see global.h)
- **
- */
-
- BOOL InitLibraries(struct OpenStructTyp *OS)
- {
- struct OpenStructTyp *p = &OS[0];
-
- while (p->Ort != NULL)
- {
- if ((*(p->Ort) = (ULONG)OpenLibrary(p->Name,p->Version)) == NULL)
- {
- printf(" Can't open %s version %d",p->Name, p->Version);
- return FALSE;
- }
- else
- { p ++; }
- }
- return TRUE;
- }
-
-
- /*
- ** Close the Libs from the OpenStructTyp
- **
- */
- void CloseLibraries(struct OpenStructTyp *OS)
- {
- struct OpenStructTyp *p = &OS[0];
-
- while (p->Name != NULL)
- {
- CloseLibrary((void *)(*(p->Ort)));
- *(p->Ort) = NULL;
- p++;
- }
- }
- /**/
-
-
- /*
- ** This routine is for Errorhandling.
- ** It close all open thinks form the
- ** program.
- **
- */
- void myError(char *string)
- {
- if ( string != NULL)
- {
- if ( EGSRequestBase == NULL )
- {
- printf("%s\n",string);
-
- }else{
-
- ErrorReq = ER_CreateSimpleReq(NULL,(char *)string,(char *)"OK");
-
- /*
- ** Open Requester in the middle of the Screen,
- **
- ** if you could !?
- */
-
- ErrorReq->Req.Nw->Flags |= EI_WINDOWCENTER;
-
- ER_DoRequest(&(ErrorReq->Req)) ;
- }
- }
-
- if (Window)
- {
-
- ErrorReq = ER_CreateSimpleReq(NULL,
- "Hello world !|This is a Requester !","OK");
-
- ErrorReq->Req.Nw->Flags |= EI_WINDOWCENTER;
-
- ER_DoRequest(&(ErrorReq->Req)) ;
- }
-
- if ( FontforMenu )
- EG_CloseFont(FontforMenu);
-
- if ( Window )
- EI_CloseWindow(Window);
-
- if ( Menu )
- EI_FreeMenu(Menu);
-
- if ( ErrorReq )
- ER_DeleteRequest(&(ErrorReq->Req));
-
- CloseLibraries(OpenStruct);
-
- exit(0);
-
-
- }
- /**/
-
- int main(int argc, char *argv[])
- {
-
- if (argc == 2 && strcmp("?",argv[1]) == 0)
- {
- printf("Aufruf: %s\n Markus van Kempen 12 Nov 1992",argv[0]);
-
- }else
- {
-
- if ( InitLibraries(OpenStruct) == FALSE)
- myError("Can't OpenLibrary");
-
- FontforMenu = (EG_EFontPtr)EG_OpenFont((struct TextAttr *)&FontStr);
-
- if ( FontforMenu == NULL )
- myError("Could not open font");
-
- Menu=InitMenu(FontforMenu);
-
- if ( Menu == NULL )
- myError("Could not build Menu");
-
- newwin.FirstGadgets=(struct EI_Gadget *)&myBoolGadget;
- newwin.Menu=Menu;
- newwin.Title=argv[0];
-
- Window = (EI_WindowPtr)EI_OpenWindow ((struct EI_NewWindow *)&newwin);
-
- if (Window)
- {
-
- HandleEvents(Window);
-
- }else{
- myError("Could not open window");
- }
- }
- myError(NULL);
- }
-
-
-
-